package com.wffz.controller;

import com.github.pagehelper.PageInfo;
import com.wffz.comm.api.ResponseResult;
import com.wffz.po.ClientUser;
import com.wffz.po.IncomeLog;
import com.wffz.po.WithdrawRecord;
import com.wffz.service.IncomeLogService;
import com.wffz.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;

/**
 * @author sunlei
 * @className IncomeController
 * @Description
 * @date 2023-04-16 6:57
 **/
@RequestMapping("/income")
@RestController
@Slf4j
public class IncomeController {

    @Resource
    private UserService userService;

    @Resource
    private IncomeLogService incomeLogService;

    @RequestMapping("/queryIncome")
    public ResponseResult queryIncome(@RequestParam(value = "pageNum", required = true, defaultValue = "1") Integer pageNum,
                                            @RequestParam(value = "pageSize", required = true, defaultValue = "1") Integer pageSize,
                                            HttpServletRequest request) {
        Principal principal = request.getUserPrincipal();
        ClientUser clientUser = userService.findUserByUserName(principal.getName());
        PageInfo<IncomeLog> pageInfo = incomeLogService.queryIncomeLog(pageNum, pageSize, clientUser.getLoginName());
        return ResponseResult.success(pageInfo);
    }
}
